package vue;

import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionListener;

import modele.MdlListRobot;
import modele.Simulateur;

/*_____________________________________________*/
/**
 * @author ARNAL - IMBERT
 *
 */
public class PnlListRobot extends JPanel
{
	MdlListRobot mdl;
	JList lst;
	/**
	 */
	private static final long serialVersionUID = 1L;
	
	public PnlListRobot(ListSelectionListener ctrl, Simulateur sim)
	{
		
		mdl = new MdlListRobot(sim);
		
		lst = new JList(mdl);		
		lst.addListSelectionListener( ctrl);
		
		JScrollPane scroll = new JScrollPane(lst);
		 scroll.setPreferredSize(new Dimension(90,90));
		 scroll.setColumnHeaderView(new JLabel("Les Robots"));
		add(scroll);
	}
	
	public void maj(int index)
	{
		lst.setSelectedIndex(index);
		lst.ensureIndexIsVisible(index);
		mdl.MAJ(index) ;
	}

	
}
